<html>
<head>
<meta charset="utf-8">
<title>统计每个行业商家数量</title>
<script type="text/javascript" src="js/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript" src="js/handlebars-min-1.3.0.js"></script>
<script type="text/javascript" src="js/highcharts.js"></script>
<script type="text/javascript" src="js/exporting.js"></script>

<link rel="stylesheet" href="css/style.css">
</head>
<body>
<h1>统计每个行业商家数量</h1>
<div id="" class="categorystat_shopnum">
    <div id="container" style="min-width: 500px; height: 400px; margin: 0 auto"></div>
    <div id="test" class="test">
        <ul id="" class=""></ul><!-- / -->
    </div><!-- / -->
    <div id="" class="test2">
        
    </div><!-- / -->
</div><!-- / -->


<script>
function consolelog(message){
    var console = document.getElementById('debuginfo');
    if (console === null) {
        console = document.createElement('div');
        console.id = 'debuginfo';
        console.style.border = '1px solid #f60';
        console.style.position = 'absolute';
        console.style.top = '0';
        console.style.bottom = '0';
        console.style.width = '100px';
        console.style.height = '100px';
    } else{};
    console.innerHTML += '<p>'+ message +'</p>';
}
consolelog();
jQuery.ajax({
    type:'get',
    url:apiURL+'categorystat_shopnum',
    data:{
        sign:key
    },
    dataType : 'jsonp',
    async:false,
    jsonp: "callback",
    jsonpCallback:"dataList",
    success : function (myData) {
        document.cookie = encodeURIComponent('name')+ '=' + encodeURIComponent('高海');

        var data = [];
        var a=myData.data.percentlist;
        console.log(a.length);
        if (a.length>0) {
            for (var i = 0; i < a.length; i++) {
                var hangyedaima = a[i].category_code,
                    baifenbi = a[i].percent,
                    str ='';
                //str +='<li>行业：'+hangyeNum[hangyedaima]+'百分比：'+toPercent(baifenbi)+'</li>';
                //$('.test').find('ul').append(str);
                data.push([hangyeNum[hangyedaima],baifenbi]);
            };
                console.log(data);

            
        } else{};

        console.log(data[0]);

        function zhuzhuang_pic () {
            $('#container').highcharts({
                chart: {
                    type: 'column'
                },
                title: {
                    text: '每个行业（类目）的商家数量柱状图展示'
                },
                subtitle: {
                    text: '来源: <a href="http://www.miningdata.com.cn">miningdata</a>'
                },
                xAxis: {
                    type: 'category',
                    labels: {
                        rotation: -45,
                        align: 'right',
                        style: {
                            fontSize: '13px',
                            fontFamily: 'Verdana, sans-serif'
                        }
                    }
                },
                yAxis: {
                    min: 0,
                    title: {
                        text: '该行业 (单位：%)'
                    }
                },
                legend: {
                    enabled: false
                },
                tooltip: {
                    pointFormat: '该行业占比: <b>{point.y:.1f} %</b> 统计时间：2014-6',
                },
                series: [{
                    name: 'Population',
                    data: data,

                    dataLabels: {
                        enabled: true,
                        rotation: -90,
                        color: '#FFFFFF',
                        align: 'right',
                        x: 4,
                        y: 0.1,
                        style: {
                            fontSize: '13px',
                            fontFamily: 'Verdana, sans-serif',
                            textShadow: '0 0 3px black'
                        }
                    }
                }]
            });
        };
        zhuzhuang_pic();

        
     
    },
    error : function (){
        console.log('error');

    }
});




</script>
</body>
</html>